﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace swfupload.Controllers
{
    public class CommonController : Controller
    {
        //
        // GET: /Common/

        public ContentResult Upload()
        {
            var image = Request.Files[0];
            string relativeFolder = "/upload/";
            if (image != null && image.ContentLength > 0)
            {
                string localFolder = Server.MapPath(relativeFolder);
                if (!Directory.Exists(localFolder))
                {
                    Directory.CreateDirectory(localFolder);
                }
                string fileName = Guid.NewGuid().ToString() + ".jpg";
                image.SaveAs(localFolder + fileName);
                return Content(relativeFolder + fileName);
            }
            return null;
        }

    }
}
